package edu.uwlax.cs.oayonlinestore.client.utils;

import com.google.gwt.user.client.ui.ListBox;

public class SelectionList extends ListBox {

	public SelectionList() {
		super();
	}

	public SelectionList(String[] items) {
		super();
		for (int i = 0; i < items.length; i++)
			addItem(items[i], items[i]);
	}

	public String getSelection() {
		return getValue(getSelectedIndex());
	}

	public void setSelection(String val) {
		if ((val != null) && val.length() != 0)
			for (int i = 0; i < getItemCount(); i++)
				if (getValue(i).equals(val)) {
					setSelectedIndex(i);
					return;
				}
		setSelectedIndex(0);
	}

}
